package com.gyms.activity;

import android.os.Bundle;
import android.support.design.widget.TabLayout;
import android.support.v4.app.Fragment;

import com.gyms.R;
import com.gyms.adapter.ComTabViewPagerAdapter;
import com.gyms.base.MyAutoLayoutActivity;
import com.gyms.fragment.MyCourseCollectFragment;
import com.gyms.fragment.GymCollectFragment;
import com.gyms.manager.TitleManager;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

import butterknife.BindView;
import weight.CustomViewPager;

/**
 * 我的收藏 ltx
 */
public class CollectionActivity extends MyAutoLayoutActivity {
    @BindView(R.id.id_view_pager)
    CustomViewPager mVpCollection;
    /**
     * 存放子Fragment
     **/
    private List<Fragment> mCollectionFragments = new ArrayList<>();
    //TabLayout 相关
    @BindView(R.id.tab_collection)
    TabLayout mTabCollection;//收藏Tab
    private ArrayList<String> mTabStrs;

    @Override
    protected void setTitleTheme() {
        mTheme = TitleManager.TitleTheme.White;
    }

    @Override
    protected int getLayoutResId() {
        return R.layout.activity_collection;
    }

    @Override
    protected void initView() {
        setBack();
        setTitle(getString(R.string.my_collection));
        createLoadingView(getString(R.string.str_loading),true);
        initFragments();
        initViewPager();
    }

    private void initFragments() {
        Bundle bundle = getIntent().getExtras();
        // 添加子Fragment到List，进行维护
        GymCollectFragment mGymCollection = new GymCollectFragment();
        MyCourseCollectFragment mCourseCollection = new MyCourseCollectFragment();
        mGymCollection.setArguments(bundle);
        mCourseCollection.setArguments(bundle);
        mCollectionFragments.add(mGymCollection);
        mCollectionFragments.add(mCourseCollection);
        mTabStrs=new ArrayList<>(Arrays.asList(getString(R.string.str_gymnasiums),getString(R.string.str_course)));
    }

    private void initViewPager() {
        ComTabViewPagerAdapter mCvColletionAdapter=new ComTabViewPagerAdapter(getSupportFragmentManager(),mCollectionFragments,mTabStrs);
        mVpCollection.setAdapter(mCvColletionAdapter);
        mTabCollection.setupWithViewPager(mVpCollection);
    }

    @Override
    protected void setListener() {
    }

    @Override
    protected void processLogic() {

    }
}
